The operation monitoring services in OPC Wizard allow your code to receive information about the status of OPC UA server operations, such as whether the server endpoints have been successfully opened, and how and when are OPC UA clients connecting and disconnecting from the server. The operation monitoring services are purely for informational purposes, diagnostics and troubleshooting; you absolutely do not have to use these services if you do not want to.
In order for OPC UA server to be of any use in the OPC UA system, it needs to make its endpoints available ("open" them) for OPC UA client connections. The OPC Wizard servers implemented with EasyUAServer Class have one or more configurable endpoints. Depending on the transport protocol, "opening" the endpoint might mean different things. In case of TCP endpoints, opening an OPC UA endpoint requires creating a TCP socket that listens for incoming connection attempts.
When the Start Method on the EasyUAServer Class is called, the OPC Wizard tries to open all its configured endpoints, and keep them open until the Stop Method is called. For various reasons, an attempt to open the endpoint may fail. In case of TCP sockets, this is typically because some other application on the system is already using the socket with the same port number on the same network interface (it may be another OPC UA server misconfigured to use the same port, or even another instance of the same OPC UA server, running by mistake). If opening any of the server endpoints fails, the OPC Wizard will continue running, and will repeatedly try to re-open the endpoint.
The status of the OPC UA server endpoints is reported through the IEasyUAServerEndpointMonitoring service. Due to its importance, the IEasyUAServerEndpointMonitoring Interface is also implemented directly on the EasyUAServer Class, and you can therefore directly add event handlers for its events on the server object, without having to obtain the service first.
The EndpointStateChanged Event on this service interface is raised when the state of the OPC UA server endpoint has changed. You receive notifications when the endpoint is opening, when it is (successfully) open, when it is closing, and when it has closed (which may be due to a failure during opening). The event notification passes to you an instance of the EasyUAServerEndpointStateChangedEventArgs Class, which contains data about the condition of the server endpoint. The EndpointUrlString Property (and EndpointUrl Property) contain the URL of the endpoint, and the MessageSecurityModes Property contains its effective message security modes. The ConnectionState Property indicates the state of the server endpoint (it is open when the IsConnected Property is true). The Exception Property contains a null reference in case of success, or it contains an exception object in case of problems.
Note that the information provided by this event should be used for oversight, informational and diagnostics purposes only. Specifically, you should not use it to attempt to implement any error recovery mechanism, because error recovery is already built into the OPC Studio software, and having your own mechanism would inevitably cause conflicts.
OPC UA clients connect to the OPC UA server endpoints, perform some operations, and then disconnect (a client may even be connected multiple times to the same OPC UA server at the same time). In order to monitor these OPC UA client connections on the server side, you can use the IEasyUAServerConnectionMonitoring service.
This service provide two main events that you can handle:
You can use these events for custom handling or logging of connections and disconnections. The service also provides the ClientSessionCount Property, which contains the number of client sessions that are currently connected to the server.
When the ClientSessionConnected Event or ClientSessionDisconnected Event is raised, your event handler receives an instance of the EasyUAClientSessionConnectionEventArgs Class as the event arguments. Following information is available to you from this class: